<template>
  <div class="bh-container">
    <!-- 表格 -->
    <user-table
      ref="table"
      @open-add="() => modal.openAdd()"
      @open-update="(e) => modal.openUpdate(e)"
      @open-reset-password="(e) => resetModal.open(e)"
      @open-grant-role="(e) => roleModal.open(e)"
    ></user-table>
    <!-- 添加修改模态框 -->
    <user-from ref="modal" @restart="() => table.restartCallback()"></user-from>
    <!-- 重置密码模态框 -->
    <user-reset-password-form ref="resetModal" />
    <!-- 分配角色模态框 -->
    <user-role-form ref="roleModal" @restart="() => table.restartCallback()" />
  </div>
</template>

<script lang="ts" setup>
  import { ref, onBeforeMount } from 'vue';
  import UserTable from './components/user-table.vue';
  import UserFrom from './components/user-from.vue';
  import UserResetPasswordForm from './components/user-reset-password-form.vue';
  import UserRoleForm from './components/user-role-form.vue';

  const render = ref(false);
  const table = ref();
  const modal = ref();
  const resetModal = ref();
  const roleModal = ref();

  onBeforeMount(async () => {
    render.value = true;
  });
</script>

<style scoped lang="less"></style>
